package dawnland03.data.map.model;

/**
 * User: Petru Obreja (obrejap@yahoo.com)
 * Date: Sep 15, 2009
 * Time: 7:09:38 PM
 */
public class MatrixCell {
    private final Integer id;
    private final Integer x;
    private final Integer y;
    private final Integer type;
    private Integer roadLevel;
    private final Boolean evenRow;

    public MatrixCell(Integer id, Integer x, Integer y, Integer type, Integer roadLevel) {
        this.id = id;
        this.x = x;
        this.y = y;
        this.type = type;
        this.roadLevel = roadLevel;
        evenRow = (y % 2 == 1);
    }

    public Integer getId() {
        return id;
    }

    public Integer getX() {
        return x;
    }

    public Integer getY() {
        return y;
    }

    public Integer getType() {
        return type;
    }

    public Integer getRoadLevel() {
        return roadLevel;
    }

    public void increaseRoadLevel(){        
        roadLevel++;
    }

    public Integer getColor() {
        return type;
    }

    public Double getCost() {
        return type.doubleValue();
    }

    public Boolean isEvenRow() {
        return evenRow;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MatrixCell node = (MatrixCell) o;

        if (type != node.type) return false;
        if (x != node.x) return false;
        if (y != node.y) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result;
        result = x;
        result = 31 * result + y;
        result = 31 * result + type;
        return result;
    }

    @Override
    public String toString() {
        return id+"("+type + ")";
    }

    public String toBigString() {
        return "N[" + id + "," + x + "," + y + "," + type + "]";
    }
}